<form class="normal_form" form-role="dialog" onsubmit="return Core.DialogForm(this)" style="padding-top:20px;margin-bottom:0;" autocomplete="off">
    <div class="row">
        <div class="field_text">花名：</div>
        <input type="text" name="nickname" value="{$res['nickname'] ?? ''}" class="input-text require" style="width:200px;" placeholder="请输入花名" />
    </div>
    <div class="row">
        <div class="field_text">部门：</div>
        <select class="z-select sel-dept" id="dept" data-style="width:200px">
            <option value="0">请选择</option>
            <!--{if ($dept ?? NULL)}-->
            <!--{foreach $dept as $key => $row}-->
            <option value="{$row['id'] ?? ''}" {if ($res['dept'] ?? 0)==($row['id'] ?? 0)} selected{/if}>{$row['title'] ?? ''}</option>
            <!--{/foreach}-->
            <!--{/if}-->
        </select>
    </div>
    <div class="row">
        <div class="field_text">角色：</div>
        <select class="z-select sel-group" id="group" data-style="width:200px">
            <option value="0">请选择</option>
            <!--{if ($group ?? NULL)}-->
            <!--{foreach $group as $key => $row}-->
            <option value="{$row['id'] ?? ''}" {if ($res['group'] ?? 0)==($row['id'] ?? 0)} selected{/if}>{$row['title'] ?? ''}</option>
            <!--{/foreach}-->
            <!--{/if}-->
        </select>
    </div>
    <div class="row">
        <div class="field_text">性别：</div>
        <select class="z-select sel-gender" id="gender" data-style="width:200px">
            <option value="0">请选择</option>
            <option value="1" {if ($res['gender'] ?? 0)==1} selected{/if}>男</option>
            <option value="2" {if ($res['gender'] ?? 0)==2} selected{/if}>女</option>
        </select>
    </div>
    <div class="row form-footer-bar">
        <p class="colortip"></p>
        <button class="btn" role="btn-cancel">取消</button>
        <button class="btn btn-primary" type="submit" role="btn-submit">保存</button>
    </div>
</form>
<script type="text/javascript">
Core.DialogForm = function(form){    
    var form = $(form);
    var p = {
        'nickname' : form.find(":text[name='nickname']").val(),
        'dept'     : form.find(".sel-dept").getZsValue(),
        'group'    : form.find(".sel-group").getZsValue(),
        'gender'   : form.find(".sel-gender").getZsValue(),
        //'attn'     : form.find(".sel-attn").getZsValue(),
    }
    if (!Core.rule('*',p['nickname'])) {
        form.find("p.colortip").html('请输入花名!');return false;
    } else if (!Core.rule('intps',p['dept'])) {
        form.find("p.colortip").html('请选择部门!');return false;
    } else if (!Core.rule('intps',p['group'])) {
        form.find("p.colortip").html('请选择角色!');return false;
    } else if (!Core.rule('intps',p['gender'])) {
        form.find("p.colortip").html('请选择性别!');return false;
    }
    
    form.find(":button").attr('disabled','disabled');
	$.ajax({type : "POST",dataType: "json",cache : false, url : "{$_G['_mc_'] ?? ''}/edit/uid/{$res['uid'] ?? ''}?r="+Math.random(),data : p,success: function(data){
	   try{
		   if (data['state'] == 'y'){
			   $("#datalist").datagrid('reload');$(form).dialogClose();
		   } else {
			   form.find(":button").removeAttr('disabled');form.find("p.colortip").html(data['msg']);return false;
		   }
	   }catch(e){form.find(":button").removeAttr('disabled');form.find("p.colortip").html('数据提交失败!');return false;}
	}});
	return false;
}
</script>